<template>

  <div class="card">
    <div class="card-img">
      <!-- 视频图片 -->
      <a :href="dataLinkUrl" class="card-picture">
        <img :src="data.cover[0]">
      </a>
    </div>

    <!-- 卡片标题和浏览量、点赞、收藏等 -->
    <div class="card-main">
      <div class="card-title">
        <span class="production">作品</span>
        <span class="title">{{ data.title }}</span>
      </div>

      <p class="browse-people">
        xxx人浏览
      </p>

      <!-- 点赞、消息、收藏 -->
      <ul>
        <li>
          <i class="iconfont icon-dianzan"></i>
          <span>0</span>
        </li>
        <li>
          <i class="iconfont icon-xiaoxi"></i>
          <span>12</span>
        </li>
        <li>
          <i class="iconfont icon-star"></i>
          <span>100</span>
        </li>
      </ul>
    </div>

    <!-- 分割线 -->
    <!-- <el-divider /> -->
    <!-- <hr style="background-color: #fff;"> -->
    <div style="height: 1px; background-color: #ccc;"></div>

    <!-- 卡片底部 -->
    <div class="card-footer">
      <div class="footer-l">
        <div class="avatar">
          <img :src="data.creatorBackup.avatar" class="avatar">
        </div>
        <span>{{ data.creatorBackup.name }}</span>
      </div>
      <span class="time-date">{{createTime}}</span>
    </div>
  </div>
</template>

<script setup lang='ts'>
import moment from 'moment';
import { computed } from 'vue';

const props = defineProps(['data']);

const createTime = computed(() => {
  // 将当前的时间戳转换为日期的格式
  return moment(props.data.createTime).format('MM-DD');
})

// 替换为正确的链接路径
const dataLinkUrl = computed(() => {
  const rightUrl = props.data.router.replace('wudao://','https://www.');
  return rightUrl
})


</script>

<style lang="less" scoped>
.card {
  float: left;
  width: 224px;
  height: 280px;
  background-color: #fff;
  border-radius: 5px;
  margin: 0 20px 20px 0;
  overflow: hidden;

  // 卡片头部
  .card-img {
    overflow: hidden;
    .card-picture {
      display: block;
      width: 100%;
      height: 126px;
      background-color: #333;
    }

    img {
      width: 100%;
      // height: 100%;
      // background-size: cover;
    }
  }

  // 卡片主体
  .card-main {
    padding: 10px;

    .card-title {
      display: flex;
      line-height: 20px;
      margin-bottom: 20px;

      .production {
        font-size: 12px;
        border: 1px solid #333;
        border-radius: 4px;
        margin-right: 10px;
      }

      .title {
        display: block;
        width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    .browse-people {
      font-size: 12px;
      color: #ccc;
      margin-bottom: 4px;
    }

    ul {
      display: flex;

      li {
        margin-right: 10px;

        i {
          color: #ccc;
          margin-right: 4px;
        }
      }

      span {
        font-size: 12px;
        color: #ccc;
      }
    }
  }

  // 分割线
  .el-divider {
    margin: 0;
  }

  // 卡片底部
  .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    font-size: 12px;

    .footer-l {
      display: flex;
      justify-content: space-around;
      align-items: center;

      .avatar {
        width: 30px;
        height: 30px;
        background-color: #ccc;
        border-radius: 50%;
        margin-right: 10px;
      }

      span {
        width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    .time-date {
      color: #ccc;
    }
  }

}
</style>